from base.mongobase import MongoBase


def get_issues_users(issues_id, user_id=None, sub_type=""):
    mongo = MongoBase("")
    sql = {"issuesId": issues_id, "subType": sub_type, "disabled": False}
    filters = {"userId": 1, "issuesId": 1, "subType": 1, "productId": 1, "productName": 1}
    if user_id:
        sql.update({"userId": user_id})
        r0 = mongo.get_data(collection=f"ref_{1 if user_id%2 else 0}", sql=sql, filters=filters)
    else:
        r0 = mongo.get_data(collection="", sql=sql, filters=filters)
        r1 = mongo.get_data(collection="", sql=sql, filters=filters)
        r0.extend(r1)
    return r0, len(r0)


from pprint import pprint

pprint(get_issues_users(""))
